<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.controller');

class PropertiesControllerSearchajax extends JController
{
	function display()
	{
		parent::display();
	}


	function SearchAjax()
	{

		jimport( 'joomla.application.component.helper' );
		$db 	=& JFactory::getDBO();
		$component = JComponentHelper::getComponent( 'com_properties' );
		$params = new JParameter( $component->params );
		//print_r($params);
		$moduleclass_sfx    = $params->get( 'moduleclass_sfx' );
		$ms_keyword 		= $params->get( 'ms_keyword' ) ;
		$ms_category 		= $params->get( 'ms_category' ) ;
		$ms_locality 		= $params->get( 'ms_locality' ) ;
		$ms_price	 		= $params->get( 'ms_price' ) ;
		$ms_footage 		= $params->get( 'ms_footage' ) ;
		$ms_bedrooms 		= $params->get( 'ms_bedrooms' ) ;
		$ms_bathrooms 		= $params->get( 'ms_bathrooms' ) ;
		$ms_parking 		= $params->get( 'ms_parking' ) ;
		$ms_postcoderadius 	= $params->get( 'ms_postcoderadius' ) ;
		$Rminprice	 		= $params->get( 'minprice' ) ;
		$Rmaxprice	 		= $params->get( 'maxprice' ) ;
		$simbolprice	 	= $params->get( 'simbolprice' ) ;

		$cyid = JRequest::getVar('cyid');
		$sid = JRequest::getVar('sid');
		$lid = JRequest::getVar('lid');
		$cid = JRequest::getVar('cid');
		$tid = JRequest::getVar('tid');

		$query = 'SELECT * FROM #__properties_country WHERE published = 1 ORDER BY name';
		$db->setQuery($query);
		$Countries = $db->loadObjectList();

		$cyitems 	= array();
		$cyitems[] 	= JHTML::_('select.option',  '0', JText::_( 'All Countries' ) );

		foreach ( $Countries as $cyitem ) {
			$cyitems[] = JHTML::_('select.option',  $cyitem->id, $cyitem->name );
		}
		$javascript = 'onChange="SearchAjax(this.value,0,0,0,0)"';
		$ComboCountries = JHTML::_('select.genericlist',   $cyitems, 'cyid', 'class="select_search"'. $javascript, 'value', 'text', $cyid );
		echo '<div class="tres_selects">';
		echo '<div class="combo_search">'.$ComboCountries.'</div>' ;


		$sitems 	= array();
		$sitems[] 	= JHTML::_('select.option',  '0', JText::_( 'All States' ) );
		if($cyid){
			$query = 'SELECT * FROM #__properties_state WHERE published = 1 AND parent = '.$cyid.' ORDER BY name';
			$db->setQuery($query);
			$States = $db->loadObjectList();

			foreach ( $States as $sitem ) {
				$sitems[] = JHTML::_('select.option',  $sitem->id, $sitem->name );
			}

		}
		$javascript = 'onChange="SearchAjax('.$cyid.',this.value,0,0,0)"';
		$ComboStates = JHTML::_('select.genericlist',   $sitems, 'sid', 'class="select_search"'. $javascript, 'value', 'text', $sid );
		echo '<div class="combo_search">'.$ComboStates.'</div>' ;

		$litems 	= array();
		$litems[] 	= JHTML::_('select.option',  '0', JText::_( 'All Localities' ) );
		if($sid){
			$query = 'SELECT * FROM #__properties_locality WHERE published = 1 AND parent = '.$sid.' ORDER BY name';
			$db->setQuery($query);
			$Localities = $db->loadObjectList();
			foreach ( $Localities as $litem ) {
				$litems[] = JHTML::_('select.option',  $litem->id, $litem->name );
			}
		}
		$javascript = 'onChange="SearchAjax('.$cyid.','.$sid.',this.value,0,0)"';
		$ComboLocalities = JHTML::_('select.genericlist',   $litems, 'lid', 'class="select_search"'. $javascript, 'value', 'text', $lid );
		echo '<div class="combo_search">'.$ComboLocalities.'</div>' ;
		echo '</div>' ;


		echo '<div class="separator_search"></div>' ;
		echo '<div class="dos_selects">';

		$query = 'SELECT * FROM #__properties_category WHERE published = 1 ORDER BY name';
		$db->setQuery($query);
		$Categories = $db->loadObjectList();
		$citems 	= array();
		$citems[] 	= JHTML::_('select.option',  '0', JText::_( 'All Categories' ) );
		foreach ( $Categories as $citem ) {
			$citems[] = JHTML::_('select.option',  $citem->id, $citem->name );
		}
		$javascript = 'onChange="SearchAjax('.$cyid.','.$sid.','.$lid.',this.value,0)"';
		$ComboCategories = JHTML::_('select.genericlist',   $citems, 'cid', 'class="select_search"'. $javascript, 'value', 'text', $cid );
		echo '<div class="combo_search">'.$ComboCategories.'</div>' ;


		$query = 'SELECT * FROM #__properties_type WHERE published = 1 ORDER BY name';
		$db->setQuery($query);
		$Types = $db->loadObjectList();
		$titems 	= array();
		$titems[] 	= JHTML::_('select.option',  '0', JText::_( 'All Types' ) );
		foreach ( $Types as $titem ) {
			$titems[] = JHTML::_('select.option',  $titem->id, $titem->name );
		}
		$javascript = 'onChange="SearchAjax('.$cyid.','.$sid.','.$lid.','.$cid.',this.value)"';
		$ComboTypes = JHTML::_('select.genericlist',   $titems, 'tid', 'class="select_search"'. $javascript, 'value', 'text', $tid );
		echo '<div class="combo_search">'.$ComboTypes.'</div>' ;





		echo '</div>' ;
		echo '<div class="separator_search"></div>' ;
		echo '<div class="tres_selects">';
		if ($ms_bedrooms) {

			$Md[0]->id_dormitorios=0;
			$Md[0]->dormitorios=JText::_('Bedrooms');
			$Md[1]->id_dormitorios=1;
			$Md[1]->dormitorios=JText::_('1 or more');
			$Md[2]->id_dormitorios=2;
			$Md[2]->dormitorios=JText::_('2 or more');
			$Md[3]->id_dormitorios=3;
			$Md[3]->dormitorios=JText::_('3 or more');
			$Md[4]->id_dormitorios=4;
			$Md[4]->dormitorios=JText::_('4 or more');
			$Md[5]->id_dormitorios=5;
			$Md[5]->dormitorios=JText::_('5 or more');

			$dormitorios       = JHTML::_('select.genericlist',   $Md, 'id_bedrooms', 'class="select_search" ','id_dormitorios', 'dormitorios',  $id_dormitorios);

			echo '<div class="combo_search">'.$dormitorios.'</div>' ;

		}

		if ($ms_bathrooms) {

			$Mb[0]->id_bathrooms=0;
			$Mb[0]->bathrooms=JText::_('Bathrooms');
			$Mb[1]->id_bathrooms=1;
			$Mb[1]->bathrooms=JText::_('1 or more');
			$Mb[2]->id_bathrooms=2;
			$Mb[2]->bathrooms=JText::_('2 or more');
			$Mb[3]->id_bathrooms=3;
			$Mb[3]->bathrooms=JText::_('3 or more');
			$Mb[4]->id_bathrooms=4;
			$Mb[4]->bathrooms=JText::_('4 or more');
			$Mb[5]->id_bathrooms=5;
			$Mb[5]->bathrooms=JText::_('5 or more');

			$bathrooms       = JHTML::_('select.genericlist',   $Mb, 'id_bathrooms', 'class="select_search"','id_bathrooms', 'bathrooms',  $id_bathrooms);

			echo '<div class="combo_search">'.$bathrooms.'</div>' ;

		}

		if ($ms_parking) {

			$Mp[0]->id_parking=0;
			$Mp[0]->parking=JText::_('Car Spaces');
			$Mp[1]->id_parking=1;
			$Mp[1]->parking=JText::_('1 or more');
			$Mp[2]->id_parking=2;
			$Mp[2]->parking=JText::_('2 or more');
			$Mp[3]->id_parking=3;
			$Mp[3]->parking=JText::_('3 or more');
			$Mp[4]->id_parking=4;
			$Mp[4]->parking=JText::_('4 or more');
			$Mp[5]->id_parking=5;
			$Mp[5]->parking=JText::_('5 or more');

			$parking       = JHTML::_('select.genericlist',   $Mp, 'id_parking', 'class="select_search"','id_parking', 'parking',  $id_parking);


			echo '<div class="combo_search">'.$parking.'</div>' ;
			echo '</div>' ;
		}




		echo '<div class="separator_search"></div>' ;
		//Thuan edit 08-09-09 - hide min, max price
		//echo '<div class="dos_selects">';
		if ($ms_price){

			$RP = explode(';',$Rminprice);
			$Trp =  count($RP);
			$minprice[0]->id_minprice=1;
			$minprice[0]->minprice=JText::_('Min Price');
			for($p=0;$p<$Trp;$p++){
				$minprice[$p+1]->id_minprice=$RP[$p];
				$minprice[$p+1]->minprice=JText::_($simbolprice.' '.$RP[$p]);
			}

			$minprice       = JHTML::_('select.genericlist',   $minprice, 'id_minprice', 'class="select_search"','id_minprice', 'minprice',  $id_minprice);

			//echo '<div class="combo_search">'.$minprice.'</div>' ;

			$RPx = explode(';',$Rmaxprice);
			$Trpx =  count($RPx);
			$maxprice[0]->id_maxprice=10000000;
			$maxprice[0]->maxprice=JText::_('Max Price');
			for($px=0;$px<$Trpx;$px++){
				$maxprice[$px+1]->id_maxprice=$RPx[$px];
				$maxprice[$px+1]->maxprice=JText::_($simbolprice.' '.$RPx[$px]);
			}

			$maxprice       = JHTML::_('select.genericlist',   $maxprice, 'id_maxprice', 'class="select_search"','id_maxprice', 'maxprice',  $id_maxprice);

			//echo '<div class="combo_search">'.$maxprice.'</div>' ;

		}
		//echo '</div>' ;
		//end Thuan edit 08-09-09
		echo '<div class="separator_search"></div>' ;

	
	?>


	<?php
	}
	
	function SearchAjaxBORRARARAR()
	{
		jimport( 'joomla.application.module.helper' );
		$module = JModuleHelper::getModule( 'prop_search' );
		$params = new JParameter( $module->params );
		$MostrarCarousel	= $params->get('MostrarCarousel');
		$moduleclass_sfx    = $params->get( 'moduleclass_sfx' );
		$ms_keyword 		= $params->get( 'ms_keyword' ) ;
		$ms_category 		= $params->get( 'ms_category' ) ;
		$ms_locality 		= $params->get( 'ms_locality' ) ;
		$ms_price	 		= $params->get( 'ms_price' ) ;
		$ms_footage 		= $params->get( 'ms_footage' ) ;
		$ms_bedrooms 		= $params->get( 'ms_bedrooms' ) ;
		$ms_bathrooms 		= $params->get( 'ms_bathrooms' ) ;
		$ms_parking 		= $params->get( 'ms_parking' ) ;
		$ms_postcoderadius 	= $params->get( 'ms_postcoderadius' ) ;
		$Rminprice	 		= $params->get( 'minprice' ) ;
		$Rmaxprice	 		= $params->get( 'maxprice' ) ;
		$simbolprice	 	= $params->get( 'simbolprice' ) ;
		$db 	=& JFactory::getDBO();
		$id_provincia = JRequest::getVar('id_provincia');//echo $id_provincia;
		$id_ciudad = JRequest::getVar('id_ciudad');
		$id_sector = JRequest::getVar('id_sector');
		$query = 'SELECT * FROM #__propiedades_provincias WHERE published = 1 ORDER BY nombre_provincia';
		$db->setQuery($query);

		$Provinces = $db->loadObjectList();


		$Vitems[0]->id_provincia=0;
		$Vitems[0]->nombre_provincia = JText::_('Select Province');
		foreach ( $Provinces as $Vitem ) {
			$Vitems[] = $Vitem;
		}
		$javascript = 'onChange="SearchAjax(this.value,0)"';
		$ComboProvinces        = JHTML::_('select.genericlist',   $Vitems, 'id_provincia', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"'.$javascript,'id_provincia', 'nombre_provincia',  $id_provincia);

		echo '<div class="combo" style="float: left; width: 100%; margin-bottom: 5px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Province').' </div>
<div class="select" style="float: right;">'.$ComboProvinces.'</div></div>' ;	


		$Vquery = ' SELECT * FROM #__propiedades_ciudades WHERE padre_ciudad = '.$id_provincia;

		$db->setQuery( $Vquery );
		$ciudades = $db->loadObjectList();

		$Citems[0]->id_ciudad=0;
		$Citems[0]->nombre_ciudad=JText::_('Select City');
		foreach ( $ciudades as $Citem ) {
			$Citems[] = $Citem;
		}
		$javascript = 'onChange="SearchAjax('.$id_provincia.',this.value)"';
		$Combociudad        = JHTML::_('select.genericlist',   $Citems, 'id_ciudad', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"'.$javascript,'id_ciudad', 'nombre_ciudad',  $id_ciudad);

		echo '<div class="combo" style="float: left; width: 100%; margin-bottom: 5px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('City').' </div>
<div class="select" style="float: right;">'.$Combociudad.'</div></div>' ;



		if($id_ciudad == 0){
			$Sitems[0]->id_sector=0;
			$Sitems[0]->nombre_sector=JText::_('Select Sector');

		}else{
			$Squery = ' SELECT * FROM #__propiedades_sectores WHERE padre_sector = '.$id_ciudad;

			$db->setQuery( $Squery );
			$sectores = $db->loadObjectList();

			$Sitems[0]->id_sector=0;
			$Sitems[0]->nombre_sector=JText::_('Select Sector');
			foreach ( $sectores as $Sitem ) {
				$Sitems[] = $Sitem;
			}
		}
		$javascript = 'onChange="SearchAjax('.$id_provincia.','.$id_ciudad.',this.value)"';
		$Combosector       = JHTML::_('select.genericlist',   $Sitems, 'id_sector', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"'.$javascript,'id_sector', 'nombre_sector',  $id_sector);

		echo '<div class="combo" style="float: left; width: 100%; margin-bottom: 5px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Sector').' </div>
<div class="select" style="float: right;">'.$Combosector.'</div></div>' ;







		if ($ms_price){

			$RP = explode(';',$Rminprice);
			$Trp =  count($RP);
			$minprice[0]->id_minprice=0;
			$minprice[0]->minprice=JText::_('Min Price');
			for($p=0;$p<$Trp;$p++){
				$minprice[$p+1]->id_minprice=$RP[$p];
				$minprice[$p+1]->minprice=JText::_($simbolprice.' '.$RP[$p]);
			}

			$minprice       = JHTML::_('select.genericlist',   $minprice, 'id_minprice', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_minprice', 'minprice',  $id_minprice);

			echo '<div class="combo" style="float: left; width: 100%; margin-bottom: 5px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Min Price').' </div>
<div class="select" style="float: right;">'.$minprice.'</div></div>' ;

			$RPx = explode(';',$Rmaxprice);
			$Trpx =  count($RPx);
			$maxprice[0]->id_maxprice=0;
			$maxprice[0]->maxprice=JText::_('Max Price');
			for($px=0;$px<$Trpx;$px++){
				$maxprice[$px+1]->id_maxprice=$RPx[$px];
				$maxprice[$px+1]->maxprice=JText::_($simbolprice.' '.$RPx[$px]);
			}

			$maxprice       = JHTML::_('select.genericlist',   $maxprice, 'id_maxprice', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_maxprice', 'maxprice',  $id_maxprice);

			echo '<div class="combo" style="float: left; width: 100%; margin-bottom: 5px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Max Price').' </div>
<div class="select" style="float: right;">'.$maxprice.'</div></div>' ;

		}

		if ($ms_bedrooms) {

			$Md[0]->id_dormitorios=0;
			$Md[0]->dormitorios=JText::_('Bedrooms');
			$Md[1]->id_dormitorios=1;
			$Md[1]->dormitorios=JText::_('1 or more');
			$Md[2]->id_dormitorios=2;
			$Md[2]->dormitorios=JText::_('2 or more');
			$Md[3]->id_dormitorios=3;
			$Md[3]->dormitorios=JText::_('3 or more');
			$Md[4]->id_dormitorios=4;
			$Md[4]->dormitorios=JText::_('4 or more');
			$Md[5]->id_dormitorios=5;
			$Md[5]->dormitorios=JText::_('5 or more');

			$dormitorios       = JHTML::_('select.genericlist',   $Md, 'id_dormitorios', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_dormitorios', 'dormitorios',  $id_dormitorios);

			echo '<div class="combo" style="float: left; width: 100%; margin-bottom: 5px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Bedrooms').' </div>
<div class="select" style="float: right;">'.$dormitorios.'</div></div>' ;

		}

		if ($ms_bathrooms) {

			$Mb[0]->id_bathrooms=0;
			$Mb[0]->bathrooms=JText::_('Bathrooms');
			$Mb[1]->id_bathrooms=1;
			$Mb[1]->bathrooms=JText::_('1 or more');
			$Mb[2]->id_bathrooms=2;
			$Mb[2]->bathrooms=JText::_('2 or more');
			$Mb[3]->id_bathrooms=3;
			$Mb[3]->bathrooms=JText::_('3 or more');
			$Mb[4]->id_bathrooms=4;
			$Mb[4]->bathrooms=JText::_('4 or more');
			$Mb[5]->id_bathrooms=5;
			$Mb[5]->bathrooms=JText::_('5 or more');

			$bathrooms       = JHTML::_('select.genericlist',   $Mb, 'id_bathrooms', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_bathrooms', 'bathrooms',  $id_bathrooms);

			echo '<div class="combo" style="float: left; width: 100%; margin-bottom: 5px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Bathrooms').' </div>
<div class="select" style="float: right;">'.$bathrooms.'</div></div>' ;

		}

		if ($ms_parking) {

			$Mp[0]->id_parking=0;
			$Mp[0]->parking=JText::_('Car Spaces');
			$Mp[1]->id_parking=1;
			$Mp[1]->parking=JText::_('1 or more');
			$Mp[2]->id_parking=2;
			$Mp[2]->parking=JText::_('2 or more');
			$Mp[3]->id_parking=3;
			$Mp[3]->parking=JText::_('3 or more');
			$Mp[4]->id_parking=4;
			$Mp[4]->parking=JText::_('4 or more');
			$Mp[5]->id_parking=5;
			$Mp[5]->parking=JText::_('5 or more');

			$parking       = JHTML::_('select.genericlist',   $Mp, 'id_parking', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_parking', 'parking',  $id_parking);

			echo '<div class="combo" style="float: left; width: 100%; margin-bottom: 5px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Car Spaces').' </div>
<div class="select" style="float: right;">'.$parking.'</div></div>' ;

		}
		?>
<div class="search"><input class="button" name="submit" value="Buscar"
	type="submit"></div>
<div id="progressS"></div>
		<?php

	}




















	function BuscarAjax()
	{
		jimport( 'joomla.application.component.helper' );

		$component = JComponentHelper::getComponent( 'com_propiedades' );
		$params = new JParameter( $component->params );
		//print_r($params);
		$moduleclass_sfx    = $params->get( 'moduleclass_sfx' );
		$ms_keyword 		= $params->get( 'ms_keyword' ) ;
		$ms_category 		= $params->get( 'ms_category' ) ;
		$ms_locality 		= $params->get( 'ms_locality' ) ;
		$ms_price	 		= $params->get( 'ms_price' ) ;
		$ms_footage 		= $params->get( 'ms_footage' ) ;
		$ms_bedrooms 		= $params->get( 'ms_bedrooms' ) ;
		$ms_bathrooms 		= $params->get( 'ms_bathrooms' ) ;
		$ms_parking 		= $params->get( 'ms_parking' ) ;
		$ms_postcoderadius 	= $params->get( 'ms_postcoderadius' ) ;
		$Rminprice	 		= $params->get( 'minprice' ) ;
		$Rmaxprice	 		= $params->get( 'maxprice' ) ;
		$simbolprice	 	= $params->get( 'simbolprice' ) ;



		$db 	=& JFactory::getDBO();
		$id_provincia = JRequest::getVar('id_provincia');//echo $id_provincia;
		$id_ciudad = JRequest::getVar('id_ciudad');
		$id_sector = JRequest::getVar('id_sector');
		$query = 'SELECT * FROM #__propiedades_provincias WHERE published = 1 ORDER BY nombre_provincia';
		$db->setQuery($query);

		$Provinces = $db->loadObjectList();


		$Vitems[0]->id_provincia=0;
		$Vitems[0]->nombre_provincia = JText::_('Select Province');
		foreach ( $Provinces as $Vitem ) {
			$Vitems[] = $Vitem;
		}
		$javascript = 'onChange="BuscarAjax(this.value,0)"';
		$ComboProvinces        = JHTML::_('select.genericlist',   $Vitems, 'id_provincia', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"'.$javascript,'id_provincia', 'nombre_provincia',  $id_provincia);

		echo '<div class="combo" style="float: left; width: 40%; margin-bottom: 5px; margin-left: 30px;">
<div class="label" style=" text-align: rigth; float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Province').' </div>
<div class="select" style="float: right;">'.$ComboProvinces.'</div></div>' ;	






		if ($ms_bedrooms) {

			$Md[0]->id_dormitorios=0;
			$Md[0]->dormitorios=JText::_('Bedrooms');
			$Md[1]->id_dormitorios=1;
			$Md[1]->dormitorios=JText::_('1 or more');
			$Md[2]->id_dormitorios=2;
			$Md[2]->dormitorios=JText::_('2 or more');
			$Md[3]->id_dormitorios=3;
			$Md[3]->dormitorios=JText::_('3 or more');
			$Md[4]->id_dormitorios=4;
			$Md[4]->dormitorios=JText::_('4 or more');
			$Md[5]->id_dormitorios=5;
			$Md[5]->dormitorios=JText::_('5 or more');

			$dormitorios       = JHTML::_('select.genericlist',   $Md, 'id_dormitorios', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_dormitorios', 'dormitorios',  $id_dormitorios);

			echo '<div class="combo" style="float: left; width: 40%; margin-bottom: 5px; margin-left: 30px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Bedrooms').' </div>
<div class="select" style="float: right;">'.$dormitorios.'</div></div>' ;

		}















		$Vquery = ' SELECT * FROM #__propiedades_ciudades WHERE padre_ciudad = '.$id_provincia;

		$db->setQuery( $Vquery );
		$ciudades = $db->loadObjectList();

		$Citems[0]->id_ciudad=0;
		$Citems[0]->nombre_ciudad=JText::_('Select City');
		foreach ( $ciudades as $Citem ) {
			$Citems[] = $Citem;
		}
		$javascript = 'onChange="BuscarAjax('.$id_provincia.',this.value)"';
		$Combociudad        = JHTML::_('select.genericlist',   $Citems, 'id_ciudad', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"'.$javascript,'id_ciudad', 'nombre_ciudad',  $id_ciudad);

		echo '<div class="combo" style="float: left; width: 40%; margin-bottom: 5px; margin-left: 30px;">
<div class="label" style=" text-align: rigth;float: left;font-size: 10px; padding-top: 3px;">'.JText::_('City').' </div>
<div class="select" style="float: right;">'.$Combociudad.'</div></div>' ;












		if ($ms_bathrooms) {

			$Mb[0]->id_bathrooms=0;
			$Mb[0]->bathrooms=JText::_('Bathrooms');
			$Mb[1]->id_bathrooms=1;
			$Mb[1]->bathrooms=JText::_('1 or more');
			$Mb[2]->id_bathrooms=2;
			$Mb[2]->bathrooms=JText::_('2 or more');
			$Mb[3]->id_bathrooms=3;
			$Mb[3]->bathrooms=JText::_('3 or more');
			$Mb[4]->id_bathrooms=4;
			$Mb[4]->bathrooms=JText::_('4 or more');
			$Mb[5]->id_bathrooms=5;
			$Mb[5]->bathrooms=JText::_('5 or more');

			$bathrooms       = JHTML::_('select.genericlist',   $Mb, 'id_bathrooms', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_bathrooms', 'bathrooms',  $id_bathrooms);

			echo '<div class="combo" style="float: left; width: 40%; margin-bottom: 5px; margin-left: 30px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Bathrooms').' </div>
<div class="select" style="float: right;">'.$bathrooms.'</div></div>' ;

		}














		if($id_ciudad == 0){
			$Sitems[0]->id_sector=0;
			$Sitems[0]->nombre_sector=JText::_('Select Sector');

		}else{
			$Squery = ' SELECT * FROM #__propiedades_sectores WHERE padre_sector = '.$id_ciudad;

			$db->setQuery( $Squery );
			$sectores = $db->loadObjectList();

			$Sitems[0]->id_sector=0;
			$Sitems[0]->nombre_sector=JText::_('Select Sector');
			foreach ( $sectores as $Sitem ) {
				$Sitems[] = $Sitem;
			}
		}
		$javascript = 'onChange="BuscarAjax('.$id_provincia.','.$id_ciudad.',this.value)"';
		$Combosector       = JHTML::_('select.genericlist',   $Sitems, 'id_sector', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"'.$javascript,'id_sector', 'nombre_sector',  $id_sector);

		echo '<div class="combo" style="float: left; width: 40%; margin-bottom: 5px; margin-left: 30px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Sector').' </div>
<div class="select" style="float: right;">'.$Combosector.'</div></div>' ;










		if ($ms_parking) {

			$Mp[0]->id_parking=0;
			$Mp[0]->parking=JText::_('Car Spaces');
			$Mp[1]->id_parking=1;
			$Mp[1]->parking=JText::_('1 or more');
			$Mp[2]->id_parking=2;
			$Mp[2]->parking=JText::_('2 or more');
			$Mp[3]->id_parking=3;
			$Mp[3]->parking=JText::_('3 or more');
			$Mp[4]->id_parking=4;
			$Mp[4]->parking=JText::_('4 or more');
			$Mp[5]->id_parking=5;
			$Mp[5]->parking=JText::_('5 or more');

			$parking       = JHTML::_('select.genericlist',   $Mp, 'id_parking', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_parking', 'parking',  $id_parking);

			echo '<div class="combo" style="float: left; width: 40%; margin-bottom: 5px; margin-left: 30px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Car Spaces').' </div>
<div class="select" style="float: right;">'.$parking.'</div></div>' ;

		}




		if ($ms_price){
			echo '<div style="float: left; width: 100%; border-top: 1px solid #cccccc; padding-top: 5px;">';
			$RP = explode(';',$Rminprice);
			$Trp =  count($RP);
			$minprice[0]->id_minprice=0;
			$minprice[0]->minprice=JText::_('Min Price');
			for($p=0;$p<$Trp;$p++){
				$minprice[$p+1]->id_minprice=$RP[$p];
				$minprice[$p+1]->minprice=JText::_($simbolprice.' '.$RP[$p]);
			}

			$minprice       = JHTML::_('select.genericlist',   $minprice, 'id_minprice', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_minprice', 'minprice',  $id_minprice);

			echo '<div class="combo" style="float: left; width: 40%; margin-bottom: 5px; margin-left: 30px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Min Price').' </div>
<div class="select" style="float: right;">'.$minprice.'</div></div>' ;

			$RPx = explode(';',$Rmaxprice);
			$Trpx =  count($RPx);

			$maxprice[0]->id_maxprice=$RPx[$Trpx-1];
			$maxprice[0]->maxprice=JText::_('Max Price');
			for($px=0;$px<$Trpx;$px++){
				$maxprice[$px+1]->id_maxprice=$RPx[$px];
				$maxprice[$px+1]->maxprice=JText::_($simbolprice.' '.$RPx[$px]);
			}

			$maxprice       = JHTML::_('select.genericlist',   $maxprice, 'id_maxprice', 'class="inputbox" size="1" style="font-size: 10px; width: 108px;"','id_maxprice', 'maxprice',  $id_maxprice);

			echo '
<div class="combo" style="float: left; width: 40%; margin-bottom: 5px; margin-left: 30px;">
<div class="label" style="float: left;font-size: 10px; padding-top: 3px;">'.JText::_('Max Price').' </div>
<div class="select" style="float: right;">'.$maxprice.'
</div>
</div>' ;
}






?>
<div id="progressB"
	style="float: left;"></div>
<div class="search" style="float: right;"><input
	value="<?php echo JText::_('Search'); ?> " class="form2_submit"
	type="submit"></div>
<?php

	}
	

	
	
	
}
?>